# Kernel config based on: arch/arm64/configs/defconfig
# Maintainer: chalkin Deng <chalkin@yeah.net>
_flavor="lenovo-q706f"
pkgname=linux-$_flavor
pkgver=6.11.0
pkgrel=3
pkgdesc="Mainline kernel fork for Lenovo SM8250"
arch="aarch64"
_carch="arm64"
url="https://github.com/silime/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
"
makedepends="
	bash
	bison
	findutils
	flex
	openssl-dev
	perl
	postmarketos-installkernel
	python3
	zstd
"
_tag="sm8250-6.11"
_config="config-$_flavor.$arch"
_commit="5640db9fd52d2fa396ebe88c58fea3134a579957"

source="
	$pkgname-$_tag.tar.gz::https://github.com/silime/linux/archive/refs/tags/$_tag.tar.gz
	$_config
"
builddir="$srcdir/linux-$_tag"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
9b1cbda916f50926eb2c848e43f1995c2d355f72b8bdfe46fbabefc4652c4f1609c9fa63a3c654ae06231b6192b86ad47bd1980ef5d9af804254bded4bf22300  linux-lenovo-q706f-sm8250-6.11.tar.gz
2a6f6895ce9872f9cc0f98a1ce0761d62bc876aeccbdb27f08aae683bdddda2d29cc9784d035301bc40f2e816c68a4c81a68d6d45d7ffb9aa156229519a30480  config-lenovo-q706f.aarch64
"
